<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="${ctxPath}/assets/images/habihou.png" rel="icon">
    <title>豆豆藤</title>
    <link rel="stylesheet" href="${ctxPath}/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/css/login.css"/>
    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>

<body>
<div class="login-wrapper">

    <div class="login-header">
         <span id="demo_project_title_header"></span>
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" class="layui-input" placeholder="账号" lay-verType="tips"
                               lay-verify="required"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" class="layui-input" placeholder="密码"
                               lay-verType="tips" lay-verify="required"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="code" type="text" class="layui-input" placeholder="验证码" lay-verType="tips"
                                       lay-verify="required-demo"/>
                            </div>
                            <div class="layui-col-xs5" style="padding-left: 10px;">
                                <img class="login-captcha" src="${ctxPath }/assets/captcha">
                            </div>
                        </div>
                    </div>
                </div>
                <!--<div class="layui-form-item">-->
                    <!--<a class="layui-link">帐号注册</a>-->
                    <!--<a class="layui-link pull-right">忘记密码？</a>-->
                <!--</div>-->
                <div class="layui-form-item">
                    <button lay-filter="loginSubmit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
            </form>
        </div>
    </div>

    <div class="login-footer">
        <p>© 2019 <a href="http://www.adinnet.cn" target="_blank">上海<span id="demo_project_title"></span>版权所有</a></p>
    </div>
</div>

<script type="text/javascript" src="${ctxPath}/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/js/common.js"></script>
<script>
    layui.config({
        base: 'assets/module/'
    }).use(['layer', 'form', 'index'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var index = layui.index;

        // 表单提交
        form.on('submit(loginSubmit)', function (obj) {
            layer.load(2);
            $.post('login', obj.field, function (res) {
                if (200 == res.code) {
                    layer.msg('登录成功', {icon: 1, time: 1500}, function () {
                        index.closeTabCache();
                        location.replace('./');
                    });
                } else {
                    layer.closeAll('loading');
                    layer.msg(res.msg, {icon: 5});
                    $('.login-captcha').trigger('click');
                }
            }, 'JSON');
            return false;
        });

        // 图形验证码
        $('.login-captcha').click(function () {
            this.src = this.src + '?t=' + (new Date).getTime();
        });
    });
</script>
</body>
</html>